package leetcode.hot100;

public class Solution240 {




    public boolean searchMatrix(int[][] matrix, int target) {
        //每次删除一行或一列，从左下角开始
        int row = matrix.length, col = matrix[0].length;
        int i = row-1, j = 0;
        while (i>=0&&j<col){
            if(matrix[i][j]==target) return true;
            else if(matrix[i][j]>target) i--;
            else j++;
        }
        //由于只能向右上走，所以如果不存在最后一定出去了
        return false;
    }
}
